<?php
/**
 * 菜单的控制器 
 */
	class MenuController extends Controller{
		private $model;

		public function __init(){

			$this->model = K('Menu');
		}

		public function index(){
			$result = $this->model->get_data(array('stid'=>Q('get.stid',0,'intval')));
			$this->assign('allData',$result);
			$this->display();
		}

		public function add(){
			if(IS_POST){
			if(!$this->model->create()) $this->error($this->model->error);
				if(!$this->model->add_data()){
					$this->error('添加失败');
				}
				$this->success('添加成功',U('index',array('stid'=>Q('post.stid'))));
			}
			$this->display();
		}



		public function edit_cate(){
			// 获得久的数据
			if(IS_POST){
				if(!$this->model->create()) $this->error($this->model->error);
				$this->model->update_data(array('mid'=>Q('post.mid',0,'intval')));
				$this->success('修改成功',U('index',array('stid'=>Q('post.stid'))));
			}
			$oldData = $this->model->get_one_data(array('mid'=>Q('get.mid',0,'intval')));
			$this->assign('oldData',$oldData);
			$this->display();
		}

		public function del(){
			$this->model->del_data(array('mid'=>Q('get.mid',0,'intval')));
			$this->success('删除成功',U('index',array('stid'=>Q('get.stid'))));
		}

	}







 ?>